import request from '@/utils/request';

// 查询生产工单列表
export function listWorkorder(query) {
  return request({
    url: '/mes/pro/workticket/list',
    method: 'get',
    params: query
  });
}

// 查询生产工单详细
export function getWorkorder(workorderId) {
  return request({
    url: '/mes/pro/workticket/' + workorderId,
    method: 'get'
  });
}
//生产工单关联的外协工单
export function getOutsourceWorkorder(query) {
  return request({
    url: '/mes/pro/workticket/outsourceWorkorder',
    method: 'get',
    params: query
  });
}
//查询某个工序下的外协生产商
export function getOutsourcedManufacture(jsonId) {
  return request({
    url: '/mes/pro/workticket/outsourcedManufacture/' + encodeURIComponent(jsonId),
    method: 'get'
  });
}


//查询生产工单，并携带每个生产工单下生产任务的情况
export function listWithTaskJson(query) {
  return request({
    url: '/mes/pro/workticket/listWithTaskJson',
    method: 'get',
    params: query
  });
}

// 新增生产工单
export function addWorkorder(data) {
  return request({
    url: '/mes/pro/workticket',
    method: 'post',
    data: data
  });
}

// 修改生产工单
export function updateWorkorder(data) {
  return request({
    url: '/mes/pro/workticket',
    method: 'put',
    data: data
  });
}

// 删除生产工单
export function delWorkorder(workorderId) {
  return request({
    url: '/mes/pro/workticket/' + workorderId,
    method: 'delete'
  });
}

// 查询物料依赖列表
export function listItems(query) {
  return request({
    url: '/mes/pro/workticket/listItems',
    method: 'get',
    params: query
  });
}

export function dofinish(workorderId) {
  return request({
    url: '/mes/pro/workticket/' + workorderId,
    method: 'put'
  });
}

// 查询生产工单列表
export function listSczxmx(query) {
  return request({
    url: '/mes/pro/workticket/sczxmx',
    method: 'get',
    params: query
  });
}

// 中止
export function died(data) {
  return request({
    url: '/mes/pro/workticket/died',
    method: 'put',
    data: data
  })
}

export function dofinish2(data) {
  return request({
    url: '/mes/pro/workticket/dofinish2',
    method: 'put',
    data: data
  });
}

// 中止
export function restart(data) {
  return request({
    url: '/mes/pro/workticket/restart',
    method: 'put',
    data: data
  })
}

// 生产工单
export function mergerWorkorder(workorderId) {
  return request({
    url: '/mes/pro/workticket/' + workorderId,
    method: 'post'
  });
}
// 查询生产工单列表
export function mergerList(query) {
  return request({
    url: '/mes/pro/workticket/mergerList',
    method: 'get',
    params: query
  });
}
//
export function addMergerList(data) {
  return request({
    url: '/mes/pro/workticket/mergerList',
    method: 'post',
    data: data
  });
}